import React, {useEffect} from 'react';
import './assets/base.css';
import { message } from "antd";
import {connect} from "react-redux";
import {ipInfoAction} from "./store/actions";
import TyreSelection from './components/tyre-selection';
import StationLayoutSelection from "./components/station-layout-selection";
import ShutdownLoadCalculationFrontThree from "./components/shutdown-load-calculation-front-three";
import DoubleWheelRolloverAngleCalculation from "./components/double-wheel-rollover-angle-calculation";
import SingleWheelRolloverAngleCalculation from "./components/single-wheel-rollover-angle-calculation";
import BufferStrokeCalculation from "./components/buffer-stroke-calculation";

function App({ ipInfoAction }) {

  useEffect(() => {
    /* ip info */
    window.electronAPI.ipInfo((_event, info) => {
      console.log('app use effect ip info:', typeof info, info);
      ipInfoAction(info);
    });

    /* command argv */
    window.electronAPI.commandArgv((_event, content) => {
      console.log('app use effect content:', typeof content, content);
    });

    /* command argv */
    window.electronAPI.createOutputFileRes((_event, val) => {
      message.success('结果文件已存到桌面！').then();
    });
  },[]);

  return <div className={"fill-full"}>
    {/* 轮胎选择 */}
    <TyreSelection />

    {/* 站位布局选型 */}
    {/* <StationLayoutSelection /> */}

    {/* 停机载荷计算（前三点式） */}
    {/* <ShutdownLoadCalculationFrontThree /> */}

    {/* 双轮侧翻角度计算 */}
    {/* <DoubleWheelRolloverAngleCalculation /> */}

    {/* 单轮侧翻角度计算 */}
    {/* <SingleWheelRolloverAngleCalculation /> */}

    {/* 缓冲器行程计算 */}
    {/* <BufferStrokeCalculation /> */}
  </div>;
}

export default connect(
  (state) => {
    return {
      ipInfo: state.ipInfoSlice,
    }
  },
  {
    ipInfoAction,
  }
)(App);
